//
//  SLAboutViewController.m
//  StarLight
//
//  Created by Duke.wu on 16/6/6.
//  Copyright © 2016年 Duke.Wu. All rights reserved.
//

#import "SLAboutViewController.h"
#import "SLUserDelegateViewController.h"
@interface SLAboutViewController ()

@property (nonatomic, strong) UIButton *userDeleBtn;

@property (nonatomic, strong) UILabel *signatureLB;

@property (nonatomic, strong) UILabel *teleLB;

@end

@implementation SLAboutViewController

- (void)viewDidLoad {
    [super viewDidLoad];
  self.title = @"关于我们";
  self.view.backgroundColor = [UIColor defeutBackgroudColor];
  
  UIImageView *logoImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"newLogo"]];
  [self.view addSubview:logoImage];
  
  UILabel *contentLabel = [UILabel labelWithFontSize:14 textColor:[UIColor blackColor]];
  contentLabel.textAlignment = NSTextAlignmentCenter;
  contentLabel.numberOfLines = 0;
  [self.view addSubview:contentLabel];
  [self.view addSubview:self.userDeleBtn];
  
  NSString *path = [[NSBundle mainBundle] pathForResource:@"about" ofType:@"txt"];
  NSError *error = [NSError new];
  NSString *content = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&error];
  contentLabel.text = content;
  
  [self.view addSubview:self.signatureLB];
  [self.view addSubview:self.teleLB];
  
  [logoImage mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.equalTo(self.mas_topLayoutGuideBottom).offset(20);
    make.centerX.equalTo(self.view);
    make.size.mas_equalTo(CGSizeMake(45, 45));
  }];
  
  [contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
    make.width.equalTo(self.view).offset(-40);
    make.centerX.equalTo(self.view);
    make.top.equalTo(logoImage.mas_bottom).offset(10);
  }];
  
  [self.userDeleBtn mas_makeConstraints:^(MASConstraintMaker *make) {
    make.width.equalTo(self.view).offset(-40);
    make.centerX.equalTo(self.view);
    make.height.equalTo(@40);
    make.bottom.equalTo(self.view.mas_bottom).offset(-30);
  }];
  
  [self.teleLB mas_makeConstraints:^(MASConstraintMaker *make) {
    make.centerX.equalTo(self.view);
    make.bottom.equalTo(self.userDeleBtn.mas_top).offset(-5);
  }];
  
  [self.signatureLB mas_makeConstraints:^(MASConstraintMaker *make) {
    make.centerX.equalTo(self.view);
    make.top.equalTo(contentLabel.mas_bottom).offset(5);
  }];
  
  
    // Do any additional setup after loading the view.
}


- (void)showDelegate{
  SLUserDelegateViewController *delegateVC = [SLUserDelegateViewController new];
  [self.navigationController pushViewController:delegateVC animated:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (UIButton *)userDeleBtn{
  if (!_userDeleBtn) {
    _userDeleBtn = [UIButton buttonWithTitle:@"用户协议"];
    [_userDeleBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    _userDeleBtn.backgroundColor = SLYellowColor;
    [_userDeleBtn addTarget:self action:@selector(showDelegate) forControlEvents:UIControlEventTouchUpInside];
  }
  return _userDeleBtn;
}

- (UILabel *)signatureLB{
  if (!_signatureLB) {
    _signatureLB = [UILabel labelWithFontSize:14 textColor:SLBlackColor];
    _signatureLB.numberOfLines = 0;
    NSString *str = @"内河航运，新码头\n逆水行舟，不进则退！\n用户至上，用心服务！\n诚信合作，互利共赢！";
    NSMutableAttributedString *atuStr = [[NSMutableAttributedString alloc] initWithString:str];
    [atuStr addAttribute:NSForegroundColorAttributeName value:SLYellowColor range:NSMakeRange(5, 1)];
    [atuStr addAttribute:NSForegroundColorAttributeName value:SLYellowColor range:NSMakeRange(9, 1)];
    [atuStr addAttribute:NSForegroundColorAttributeName value:SLYellowColor range:NSMakeRange(26, 1)];
    [atuStr addAttribute:NSForegroundColorAttributeName value:SLYellowColor range:NSMakeRange(31, 1)];
    _signatureLB.attributedText = atuStr;
    _signatureLB.textAlignment = NSTextAlignmentCenter;
  }
  return _signatureLB;
}


- (UILabel *)teleLB{
  if (!_teleLB) {
    _teleLB = [UILabel labelWithFontSize:16 textColor:SLBlackColor text:@"联系方式：15927039165"];
    _teleLB.textAlignment = NSTextAlignmentCenter;
  }
  return _teleLB;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
